<?php

namespace App\Core;

use App\Constants\AppInfo;
use Cake\Database\StatementInterface;
use Psr\Log\LoggerInterface;
use Wonfu\Core\Database\CakeConnectionWrapper as WonfuCakeConnectionWrapper;
use Wonfu\Core\Database\CakeLoggingStatementWrapper;

class CakeConnectionWrapper extends WonfuCakeConnectionWrapper
{


    /**
     * Gets the logger object
     *
     * @return LoggerInterface logger instance
     */
    public function getLogger(): LoggerInterface
    {
        /** @var MallLogger $logger */
        $logger = AppInfo::$container->get(LoggerInterface::class);
        return $logger;
    }

    protected function getCakeLoggingStatementWrapper(StatementInterface $statement)
    {
        $statement = new CarsvcCakeLoggingStatementWrapper($statement, $this->_driver);
        $statement->setLogger($this->getLogger());
        $statement->setLogHook(new CakeLogHook());
        return $statement;
    }


}